package it.marco.test.service;

import it.marco.test.dao.BaseDAO;

import java.io.Serializable;
import java.util.List;

import org.springframework.transaction.annotation.Transactional;

public class AbstractBaseService<T, ID extends Serializable> /*implements BaseService<T, Serializable> */{
	
	protected BaseDAO<T, ID> dao;
	
	
	/* (non-Javadoc)
	 * @see it.marco.test.service.BaseService#setDao(it.marco.test.dao.BaseDAO)
	 */
	@SuppressWarnings("unchecked")
	public void setDao(BaseDAO<T, Serializable> dao) {
		this.dao = (BaseDAO<T, ID>)dao;
	}


	@Transactional
	public List<T> findAll() {
		return dao.findAll();
	}


	public void delete(T entity) {
		dao.delete(entity);
		
	}


	@SuppressWarnings("unchecked")
	public T find(Serializable id) {
		return dao.find((ID)id);
	}


	public void save(T entity) {
		dao.save(entity);
	}


	public void saveOrUpdate(T entity) {
		dao.saveOrUpdate(entity);
		
	}
	
	public void update(T entity) {
		dao.update(entity);
		
	}


	
	
	
	
	
		
	

	
	
}
